package com.example.devsa_platform.pojo.doc;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.csv.CSVRecord;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@Document(indexName = "tech_culture_info", createIndex = false)
public class TechCultureDoc implements Serializable {
    @Field(name = "language_have_worked_with")
    private String languageHaveWorkedWith;

    @Field(name = "language_want_to_work_with")
    private String languageWantToWorkWith;

    @Field(name = "database_have_worked_with")
    private String databaseHaveWorkedWith;

    @Field(name = "database_want_to_work_with")
    private String databaseWantToWorkWith;

    @Field(name = "platform_have_worked_with")
    private String platformHaveWorkedWith;

    @Field(name = "platform_want_to_work_with")
    private String platformWantToWorkWith;

    @Field(name = "webframe_have_worked_with")
    private String webframeHaveWorkedWith;

    @Field(name = "webframe_want_to_work_with")
    private String webframeWantToWorkWith;

    @Field(name = "misc_tech_have_worked_with")
    private String miscTechHaveWorkedWith;

    @Field(name = "misc_tech_want_to_work_with")
    private String miscTechWantToWorkWith;

    @Field(name = "tools_tech_have_worked_with")
    private String toolsTechHaveWorkedWith;

    @Field(name = "tools_tech_want_to_work_with")
    private String toolsTechWantToWorkWith;

    @Field(name = "new_collab_tools_have_worked_with")
    private String newCollabToolsHaveWorkedWith;

    @Field(name = "new_collab_tools_want_to_work_with")
    private String newCollabToolsWantToWorkWith;

    @Field(name = "op_sys_personal_use")
    private String opSysPersonalUse;

    @Field(name = "op_sys_professional_use")
    private String opSysProfessionalUse;

    @Field(name = "office_stack_async_have_worked_with")
    private String officeStackAsyncHaveWorkedWith;

    @Field(name = "office_stack_async_want_to_work_with")
    private String officeStackAsyncWantToWorkWith;

    @Field(name = "office_stack_sync_have_worked_with")
    private String officeStackSyncHaveWorkedWith;

    @Field(name = "office_stack_sync_want_to_work_with")
    private String officeStackSyncWantToWorkWith;

    @Field(name = "ai_search_have_worked_with")
    private String aiSearchHaveWorkedWith;

    @Field(name = "ai_search_want_to_work_with")
    private String aiSearchWantToWorkWith;

    @Field(name = "ai_dev_have_worked_with")
    private String aiDevHaveWorkedWith;

    @Field(name = "ai_dev_want_to_work_with")
    private String aiDevWantToWorkWith;

    public TechCultureDoc(CSVRecord record) {
        this.languageHaveWorkedWith = getValueOrDefault(record.get("LanguageHaveWorkedWith"));
        this.languageWantToWorkWith = getValueOrDefault(record.get("LanguageWantToWorkWith"));
        this.databaseHaveWorkedWith = getValueOrDefault(record.get("DatabaseHaveWorkedWith"));
        this.databaseWantToWorkWith = getValueOrDefault(record.get("DatabaseWantToWorkWith"));
        this.platformHaveWorkedWith = getValueOrDefault(record.get("PlatformHaveWorkedWith"));
        this.platformWantToWorkWith = getValueOrDefault(record.get("PlatformWantToWorkWith"));
        this.webframeHaveWorkedWith = getValueOrDefault(record.get("WebframeHaveWorkedWith"));
        this.webframeWantToWorkWith = getValueOrDefault(record.get("WebframeWantToWorkWith"));
        this.miscTechHaveWorkedWith = getValueOrDefault(record.get("MiscTechHaveWorkedWith"));
        this.miscTechWantToWorkWith = getValueOrDefault(record.get("MiscTechWantToWorkWith"));
        this.toolsTechHaveWorkedWith = getValueOrDefault(record.get("ToolsTechHaveWorkedWith"));
        this.toolsTechWantToWorkWith = getValueOrDefault(record.get("ToolsTechWantToWorkWith"));
        this.newCollabToolsHaveWorkedWith = getValueOrDefault(record.get("NEWCollabToolsHaveWorkedWith"));
        this.newCollabToolsWantToWorkWith = getValueOrDefault(record.get("NEWCollabToolsWantToWorkWith"));
        this.opSysPersonalUse = getValueOrDefault(record.get("OpSysPersonal use"));
        this.opSysProfessionalUse = getValueOrDefault(record.get("OpSysProfessional use"));
        this.officeStackAsyncHaveWorkedWith = getValueOrDefault(record.get("OfficeStackAsyncHaveWorkedWith"));
        this.officeStackAsyncWantToWorkWith = getValueOrDefault(record.get("OfficeStackAsyncWantToWorkWith"));
        this.officeStackSyncHaveWorkedWith = getValueOrDefault(record.get("OfficeStackSyncHaveWorkedWith"));
        this.officeStackSyncWantToWorkWith = getValueOrDefault(record.get("OfficeStackSyncWantToWorkWith"));
        this.aiSearchHaveWorkedWith = getValueOrDefault(record.get("AISearchHaveWorkedWith"));
        this.aiSearchWantToWorkWith = getValueOrDefault(record.get("AISearchWantToWorkWith"));
        this.aiDevHaveWorkedWith = getValueOrDefault(record.get("AIDevHaveWorkedWith"));
        this.aiDevWantToWorkWith = getValueOrDefault(record.get("AIDevWantToWorkWith"));
    }

    private String getValueOrDefault(String value) {
        return Objects.equals(value, "NA") ? "No Answer" : value;
    }
}
